﻿using SD.WRZS.K3.ServiceFacade.KDServiceEntity.Mobile;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SDWXServer.Models
{
    [Serializable]
    public class WXPCD
    {
        public WXPCD()
        {
            this.CurrenStatus = "";
            this.ReceivedStatus = "";
            this.EntryRows = new List<WXPCDEntryRow>();
            this.LinkedPCDStatus = new List<PCDStatus>();
            this.IsOutStock = true;
            this.WLDWContactName = string.Empty;
            this.WLDWPhoneNumber = "******";
            this.WLDWAddress = string.Empty;
            this.PaiDuiWeiDu = new PaiDuiWeiDu();
            this.YuYueWeiDu = new YuYueWeiDu();
            this.YuYueObject = new YuYueObject();
            this.QuYangResult = string.Empty;
            this.QuYangResultDesc = string.Empty;
            this.AppId = string.Empty;
            this.UserToken = string.Empty;
            this.ReceivedMaxPictureCount = 5;
            this.SupplierNetQtyMaxPictureCount = 1;
            this.IsShowPCDQianZiButton = true;
            this.TruckTypeId = "555aa682e1c2c7";
            this.TruckTypeName = "普通车";
            this.WRZSClientNumber = "";
            this.Handler_Phone = "";

            this.PaiDuiName = "";
            this.PaiDuiSeq = "";
        }
        public string Id { get; set; }
        public string AppId { get; set; }
        public string UserToken { get; set; }
        public Int64 BillId { get; set; }
        public string BillNo { get; set; }

        public void BuildID()
        {
            if (this.BillId > 0L)
            {
                this.Id = string.Format("{0}_{1}_{2}", this.AppId, this.BillId, this.UserToken);
            }
            else
            {
                this.Id = string.Format("{0}_{1}_{2}_{3}_{4}", this.AppId, this.SourceBillTypeId, this.SourceBillId, this.SourceBillEntryId, this.SourceBillTruckPlanEntryId);
            }
        }

        /// <summary>
        /// 业务对象标识
        /// </summary>
        public string FormId { get; set; }
        public string BillTypeId { get; set; }
        public string BillTypeName { get; set; }

        public string BillDate { get; set; }

        public string DocumentStatus { get; set; }
        public string CancelStatus { get; set; }
        public string CloseStatus { get; set; }
        public bool IsSuspend { get; set; }
        /// <summary>
        /// RFID卡号
        /// </summary>
        public string RFIDTag { get; set; }

        /// <summary>
        /// 身份证号
        /// </summary>
        public string IDCardNo { get; set; }
        /// <summary>
        /// 往来单位
        /// </summary>
        public string WLDWName { get; set; }
        /// <summary>
        /// 往来单位联系人
        /// </summary>
        public string WLDWContactName { get; set; }
        /// <summary>
        /// 往来单位联系电话
        /// </summary>
        public string WLDWPhoneNumber { get; set; }
        /// <summary>
        /// 往来单位联系地址
        /// </summary>
        public string WLDWAddress { get; set; }

        /// <summary>
        /// 车牌号
        /// </summary>
        public string PlateNumber { get; set; }
        /// <summary>
        /// 司机
        /// </summary>
        public string Driver { get; set; }
        /// <summary>
        /// 手机号
        /// </summary>
        public string MobilePhoneNumber { get; set; }
        /// <summary>
        /// 车辆类型
        /// </summary>
        public string TruckTypeId { get; set; }
        /// <summary>
        /// 车辆类型名称
        /// </summary>
        public string TruckTypeName { get; set; }

        /// <summary>
        /// 制单人
        /// </summary>
        public string Creator { get; set; }
        /// <summary>
        /// 库存组织
        /// </summary>
        public string StockOrg { get; set; }
        public decimal WBQty1 { get; set; }
        public decimal WBQty2 { get; set; }
        public decimal WBNetQty1 { get; set; }
        public decimal WBQty3 { get; set; }
        public decimal WBQty4 { get; set; }
        public decimal WBNetQty2 { get; set; }
        public string WBQty1Time { get; set; }
        public string WBQty2Time { get; set; }
        public string WBQty3Time { get; set; }
        public string WBQty4Time { get; set; }
        public string WeightUnit { get; set; }
        /// <summary>
        /// 包装比例
        /// </summary>
        public decimal BaoZhuangBL { get; set; }

        /// <summary>
        /// 包装总重量
        /// </summary>
        public decimal BaoZhuangQty { get; set; }

        /// <summary>
        /// 港口净重
        /// </summary>
        public decimal GKNetQty { get; set; }

        /// <summary>
        /// 扣杂比例
        /// </summary>
        public decimal KouZaBL { get; set; }
        /// <summary>
        /// 扣杂数量
        /// </summary>
        public decimal KouZaQty { get; set; }
        /// <summary>
        /// 扣水份
        /// </summary>
        public decimal KouShui { get; set; }
        /// <summary>
        /// 当前车辆状态
        /// </summary>
        public string CurrenStatus { get; set; }
        /// <summary>
        /// 当前派车单状态
        /// </summary>
        public PCDStatus CurrenPCDStatus { get; set; }
        /// <summary>
        /// 下一步派车单状态
        /// </summary>
        public PCDStatus NextPCDStatus { get; set; }
        /// <summary>
        /// 整单结算数量
        /// </summary>
        public decimal JieSuanQty { get; set; }
        /// <summary>
        /// 结算单位
        /// </summary>
        public string BaseUnit { get; set; }

        public List<WXPCDEntryRow> EntryRows { get; set; }

        public string SourceBillTypeId { get; set; }
        public string SourceBillTypeName { get; set; }
        public string SourceBillNo { get; set; }
        public Int64 SourceBillId { get; set; }
        public Int64 SourceBillEntryId { get; set; }
        /// <summary>
        /// 派车计划分录内码
        /// </summary>
        public Int64 SourceBillTruckPlanEntryId { get; set; }
        /// <summary>
        /// 是否为司机
        /// </summary>
        public bool IsDriver { get; set; }
        /// <summary>
        /// 是否为客户
        /// </summary>
        public bool IsCustomer { get; set; }
        /// <summary>
        /// 是否为供应商
        /// </summary>
        public bool IsSupplier { get; set; }
        /// <summary>
        /// 是否为仓管员
        /// </summary>
        public bool IsStocker { get; set; }
        /// <summary>
        /// 是否显示到货确认按钮
        /// </summary>
        public bool IsShowPCDReceivedButton { get; set; }
        /// <summary>
        /// 是否已收货
        /// </summary>
        public bool IsReceived { get; set; }
        /// <summary>
        /// 收货状态
        /// </summary>
        public string ReceivedStatus { get; set; }
        /// <summary>
        /// 收货时间
        /// </summary>
        public DateTime? ReceivedTime { get; set; }
        /// <summary>
        /// 收货人
        /// </summary>
        public string Receiver { get; set; }
        /// <summary>
        /// 收货数量
        /// </summary>
        public decimal ReceivedQty { get; set; }
        /// <summary>
        /// 在途损耗
        /// </summary>
        public decimal ReceivedLoss { get; set; }
        /// <summary>
        /// 最大图片个数
        /// </summary>
        public Int32 ReceivedMaxPictureCount { get; set; }
        /// <summary>
        /// 二维码
        /// </summary>
        public string QRCode { get; set; }
        /// <summary>
        /// 派车单流转状态
        /// </summary>
        public List<PCDStatus> LinkedPCDStatus { get; set; }
        /// <summary>
        /// 是否出库
        /// </summary>
        public bool IsOutStock { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Note { get; set; }
        /// <summary>
        /// 仓库
        /// </summary>
        public string Stock { get; set; }
        /// <summary>
        /// 排队队列名称
        /// </summary>
        public string PaiDuiName { get; set; }
        /// <summary>
        /// 排队序号
        /// </summary>
        public string PaiDuiSeq { get; set; }
        /// <summary>
        /// 排队维度ID
        /// </summary>
        public Int64 PDWD { get; set; }
        /// <summary>
        /// 排队维度
        /// </summary>
        public PaiDuiWeiDu PaiDuiWeiDu { get; set; }
        /// <summary>
        /// 预约维度
        /// </summary>
        public YuYueWeiDu YuYueWeiDu { get; set; }
        /// <summary>
        /// 预约对象
        /// </summary>
        public YuYueObject YuYueObject { get; set; }
        /// <summary>
        /// 取样结果
        /// </summary>
        public string QuYangResult { get; set; }
        /// <summary>
        /// 取样结果描述
        /// </summary>
        public string QuYangResultDesc { get; set; }
        /// <summary>
        /// 是否显示修改按钮
        /// </summary>
        public bool IsShowPCDModifyButton { get; set; }
        /// <summary>
        /// 供应商原厂1次过磅
        /// </summary>
        public decimal SupplierWBQty1 { get; set; }
        /// <summary>
        /// 供应商原厂2次过磅
        /// </summary>
        public decimal SupplierWBQty2 { get; set; }
        /// <summary>
        /// 供应商原厂净重(矿发数)
        /// </summary>
        public decimal SupplierNetQty { get; set; }
        /// <summary>
        /// 原厂净重最大图片个数
        /// </summary>
        public Int32 SupplierNetQtyMaxPictureCount { get; set; }
        /// <summary>
        /// 是否显示打卡按钮
        /// </summary>
        public bool IsShowDKButton { get; set; }
        /// <summary>
        /// 是否显示磅单签字按钮
        /// </summary>
        public bool IsShowPCDQianZiButton { get; set; }
        /// <summary>
        /// 是否显示手工放行按钮
        /// </summary>
        public bool IsShowPCDSGFXButton { get; set; }
        /// <summary>
        /// 过磅异常处理人
        /// </summary>
        public string Handler_Phone { get; set; }
        /// <summary>
        /// 无人服务客户端编码
        /// </summary>
        public string WRZSClientNumber { get; set; }
        /// <summary>
        /// 重新理货原因
        /// </summary>
        public string ChongXinLiHuoYuanYin { get; set; }

        public static WXPCD Parse(SD.WRZS.K3.ServiceFacade.KDServiceEntity.Mobile.PCDObject obj)
        {
            var pcd = new WXPCD();
            pcd.RFIDTag = obj.RFIDTag;
            pcd.IsReceived = obj.IsReceived;
            pcd.ReceivedTime = obj.ReceivedTime;
            pcd.Receiver = obj.Receiver;
            pcd.ReceivedQty = obj.ReceivedQty;
            pcd.ReceivedLoss = obj.ReceivedLoss;
            pcd.QRCode = obj.QRCode;
            pcd.CurrenPCDStatus = obj.CurrenStatus;
            pcd.NextPCDStatus = obj.NextStatus;
            if (obj.LinkedPCDStatus != null) pcd.LinkedPCDStatus.AddRange(obj.LinkedPCDStatus);

            if (obj.Id > 0L && obj.RFIDTagStatus == "A" && obj.RFIDTag != null && obj.RFIDTag.Length >= 12)
            {
                pcd.QRCode = obj.RFIDTag;
            }

            pcd.BaoZhuangBL = obj.BaoZhuangBL;
            pcd.BaoZhuangQty = obj.BaoZhuangQty;
            pcd.BillDate = obj.BillDate.ToString("yyyy-MM-dd");
            pcd.BillId = obj.Id;
            pcd.BillNo = obj.BillNo;
            pcd.BillTypeId = obj.BillTypeId;
            pcd.BillTypeName = obj.BillTypeName;
            pcd.CancelStatus = obj.CancelStatus;
            pcd.CloseStatus = obj.CloseStatus;
            pcd.Creator = obj.Creator.Name;
            if (obj.CurrenStatus != null)
            {
                pcd.CurrenStatus = obj.CurrenStatus.Name;
            }
            pcd.DocumentStatus = obj.DocumentStatus;

            pcd.FormId = obj.FormId;
            pcd.Driver = obj.Driver;
            pcd.IDCardNo = obj.IDCardNo;
            pcd.PlateNumber = obj.PlateNumber;
            pcd.MobilePhoneNumber = obj.MobilePhoneNumber;
            pcd.IDCardNo = SetIDCardNoByAsterisk(obj.IDCardNo);
            pcd.TruckTypeId = obj.TruckTypeId;
            pcd.TruckTypeName = GetTruckTypeName(pcd.TruckTypeId);
            pcd.PDWD = obj.PDWD;
            pcd.PaiDuiWeiDu = obj.PaiDuiWeiDu;
            pcd.YuYueWeiDu = obj.YuYueWeiDu;
            if (pcd.PaiDuiWeiDu.Id > 0L)
            {
                pcd.PaiDuiName = pcd.PaiDuiWeiDu.Name;
                pcd.PaiDuiSeq = pcd.PaiDuiWeiDu.PaiDuiSeq;
            }
            if (pcd.YuYueWeiDu.Id > 0L)
            {
                pcd.PaiDuiName = pcd.YuYueWeiDu.Name;
                pcd.PaiDuiSeq = pcd.YuYueWeiDu.PaiDuiSeq;

                pcd.YuYueWeiDu.Id = 0L;
            }
            if (pcd.CurrenPCDStatus != null && pcd.CurrenPCDStatus.Id != PCDLZStatusUtil.PaiDuiZhong)
            {
                pcd.PaiDuiSeq = "";
            }
            if ((pcd.PaiDuiWeiDu.IsStopJinChang || pcd.YuYueWeiDu.IsStopJinChang) && pcd.CurrenPCDStatus != null && (pcd.CurrenPCDStatus.Id == PCDLZStatusUtil.PaiDuiZhong || pcd.CurrenPCDStatus.Id == PCDLZStatusUtil.JinChang))
            {
                pcd.PaiDuiSeq = string.Format("{0}  暂停入厂", pcd.PaiDuiSeq);
            }

            pcd.GKNetQty = obj.GKNetQty;
            pcd.IsSuspend = obj.IsSuspend;
            pcd.KouShui = obj.KouShui;
            pcd.KouZaBL = obj.KouZaBL;
            pcd.KouZaQty = obj.KouZaQty;
            pcd.StockOrg = obj.StockOrg.Name;
            pcd.WLDWName = obj.WLDWName;
            pcd.WLDWContactName = obj.WLDW_IDCardNo;
            pcd.WLDWPhoneNumber = obj.WLDW_Mobile;
            pcd.WLDWAddress = obj.WLDW_OpenBankName;
            pcd.SupplierWBQty1 = obj.SupplierWBQty1 / 1000m;
            pcd.SupplierWBQty2 = obj.SupplierWBQty2 / 1000m;
            pcd.SupplierNetQty = obj.SupplierNetQty;

            if (string.IsNullOrWhiteSpace(pcd.WLDWName))
            {
                pcd.WLDWName = pcd.StockOrg;
            }
            if (string.IsNullOrWhiteSpace(pcd.WLDWPhoneNumber))
            {
                pcd.WLDWPhoneNumber = "******";
            }
            if (string.IsNullOrWhiteSpace(pcd.WLDWAddress))
            {
                pcd.WLDWAddress = pcd.WLDWName;
            }

            pcd.Stock = obj.Stock;

            pcd.WBNetQty1 = obj.WBNetQty1;
            pcd.WBNetQty2 = obj.WBNetQty2;

            pcd.WBQty1 = obj.WBQty1;
            pcd.WBQty2 = obj.WBQty2;
            pcd.WBQty3 = obj.WBQty3;
            pcd.WBQty4 = obj.WBQty4;
            if (obj.WBQty1Time.HasValue)
            {
                pcd.WBQty1Time = obj.WBQty1Time.Value.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            }
            if (obj.WBQty2Time.HasValue)
            {
                pcd.WBQty2Time = obj.WBQty2Time.Value.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            }
            if (obj.WBQty3Time.HasValue)
            {
                pcd.WBQty3Time = obj.WBQty3Time.Value.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            }
            if (obj.WBQty4Time.HasValue)
            {
                pcd.WBQty4Time = obj.WBQty4Time.Value.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            }
            pcd.WeightUnit = obj.WeightUnit.Name;

            pcd.SourceBillTypeName = obj.SourceBillTypeName;
            pcd.SourceBillTypeId = obj.SourceBillTypeId;
            pcd.SourceBillId = obj.SourceBillId;
            pcd.SourceBillNo = obj.SourceBillNo;
            pcd.SourceBillEntryId = obj.SourceBillEntryId;
            pcd.SourceBillTruckPlanEntryId = obj.SourceBillTruckPlanEntryId;
            pcd.Note = obj.Note;
            pcd.ChongXinLiHuoYuanYin = obj.ChongXinLiHuoYuanYin;
            pcd.QuYangResult = obj.QuYangResult;
            pcd.IsOutStock = obj.IsOutStock;
            if (string.IsNullOrWhiteSpace(pcd.QuYangResult)) pcd.QuYangResult = string.Empty;

            foreach (var rowObj in obj.EntryRows)
            {
                var row = new WXPCDEntryRow();
                pcd.EntryRows.Add(row);

                row.MaterialNumber = rowObj.Material.Number;
                row.MaterialName = rowObj.Material.Name;
                row.Specification = rowObj.Material.Specification;
                row.PlanQty = rowObj.PlanQty;
                row.LiHuoQty = rowObj.LiHuoQty;
                row.LiHuoUnit = rowObj.LiHuoUnit.Name;
                row.Unit = rowObj.Unit.Name;
                row.BaseUnit = rowObj.BaseUnit.Name;
                row.JieSuanQty = rowObj.BarcodeScanRows.Sum(p => p.BaseQty);
                row.TaxPrice = rowObj.TaxPrice;
                if (rowObj.BarcodeScanRows.Count > 0)
                {
                    row.Stock = rowObj.BarcodeScanRows[0].Stock.Name;
                }
            }

            pcd.JieSuanQty = pcd.EntryRows.Sum(p => p.JieSuanQty);
            if (pcd.EntryRows.Count > 0)
            {
                pcd.BaseUnit = pcd.EntryRows[0].BaseUnit;
            }

            pcd.IsShowPCDModifyButton = true;
            if (pcd.IsOutStock)
            {
                if (pcd.IsReceived)
                {
                    pcd.ReceivedStatus = "已收货";
                }
                else
                {
                    pcd.ReceivedStatus = "等待收货";
                }
            }

            #region 特殊处理模糊化
            var bClearInfo = KD.LoginViewModel.Current != null && KD.LoginViewModel.Current.AppID == "WXServer_FuXin";
            bClearInfo = bClearInfo || (KD.LoginViewModel.Current != null && KD.LoginViewModel.Current.AppID == "WXServer_JHHX" && pcd.WLDWName != null && pcd.WLDWName.Contains("晨鸣"));
            if (bClearInfo)
            {
                pcd.WBNetQty1 = 0m;
                pcd.WBNetQty2 = 0m;

                pcd.WBQty1 = 0m;
                pcd.WBQty2 = 0m;
                pcd.WBQty3 = 0m;
                pcd.WBQty4 = 0m;
                pcd.JieSuanQty = 0m;
                pcd.EntryRows.ForEach(p =>
                {
                    p.JieSuanQty = 0m;
                    p.LiHuoQty = 0m;
                });
            }
            if (KD.LoginViewModel.Current != null && KD.LoginViewModel.Current.AppID == "WXServer_HZSW" && pcd.EntryRows.Count > 0 && pcd.EntryRows[0].MaterialName != null && pcd.EntryRows[0].MaterialName.Contains("玉米"))
            {
                pcd.JieSuanQty = 0m;
                pcd.EntryRows.ForEach(p =>
                {
                    p.JieSuanQty = 0m;
                });
            }
            #endregion

            return pcd;
        }
        public static WXPCD Parse(SD.WRZS.K3.ServiceFacade.KDServiceEntity.Mobile.PCDSourceBillObject obj)
        {
            var pcd = new WXPCD();

            pcd.BillDate = obj.BillDate.ToString("yyyy-MM-dd");
            pcd.BillId = 0L;
            pcd.BillNo = obj.BillNo;
            pcd.BillTypeId = obj.BillTypeId;
            pcd.BillTypeName = obj.BillTypeName;
            pcd.CancelStatus = obj.CancelStatus;
            pcd.CloseStatus = obj.CloseStatus;
            pcd.Creator = obj.Creator.Name;
            pcd.YuYueWeiDu = obj.PCJHItemCollection[0].YuYueWeiDu;
            pcd.YuYueObject = obj.PCJHItemCollection[0].YuYueObject;
            if (pcd.YuYueObject.CloseStatus == "B")
            {
                pcd.YuYueObject.YYDCTime = null;
                pcd.YuYueObject.XDTime = null;
            }
            if (pcd.YuYueWeiDu.Id > 0L && pcd.YuYueObject.Id > 0L && string.IsNullOrWhiteSpace(pcd.YuYueObject.DKPosition) == true)
            {
                pcd.IsShowDKButton = true;
            }

            pcd.DocumentStatus = obj.DocumentStatus;
            pcd.FormId = obj.FormId;
            pcd.Driver = obj.PCJHItemCollection[0].Driver;
            pcd.IDCardNo = obj.PCJHItemCollection[0].IDCardNo;
            pcd.PlateNumber = obj.PCJHItemCollection[0].PlateNumber;
            pcd.MobilePhoneNumber = obj.PCJHItemCollection[0].Mobile;
            pcd.IDCardNo = SetIDCardNoByAsterisk(pcd.IDCardNo);
            pcd.TruckTypeId = obj.PCJHItemCollection[0].TruckTypeId;
            pcd.TruckTypeName = GetTruckTypeName(pcd.TruckTypeId);

            pcd.IsSuspend = obj.IsSuspend;
            pcd.StockOrg = obj.StockOrg.Name;
            pcd.WLDWName = obj.WLDW.Name;
            if (string.IsNullOrWhiteSpace(pcd.WLDWName))
            {
                pcd.WLDWName = pcd.StockOrg;
            }
            pcd.Stock = obj.Stock;

            pcd.SourceBillTypeName = obj.BillTypeName;
            pcd.SourceBillTypeId = obj.BillTypeId;
            pcd.SourceBillId = obj.Id;
            pcd.SourceBillNo = obj.BillNo;
            pcd.SourceBillEntryId = obj.EntryId;
            pcd.SourceBillTruckPlanEntryId = obj.PCJHItemCollection[0].Id;
            pcd.Note = obj.Note;
            pcd.IsShowPCDQianZiButton = false;

            foreach (var rowObj in obj.PCJHItemCollection)
            {
                var row = new WXPCDEntryRow();
                pcd.EntryRows.Add(row);

                row.MaterialNumber = obj.Material.Number;
                row.MaterialName = obj.Material.Name;
                row.Specification = obj.Material.Specification;
                row.PlanQty = obj.PlanQty;
                row.LiHuoQty = 0m;
                row.LiHuoUnit = "";
                row.Unit = obj.Unit.Name;
                row.BaseUnit = "";
                row.JieSuanQty = 0m;
                row.TaxPrice = 0m;
                row.Stock = obj.Stock;
            }

            if (pcd.PaiDuiWeiDu.Id > 0L)
            {
                pcd.PaiDuiName = pcd.PaiDuiWeiDu.Name;
                pcd.PaiDuiSeq = pcd.PaiDuiWeiDu.PaiDuiSeq;
            }
            if (pcd.YuYueWeiDu.Id > 0L)
            {
                pcd.PaiDuiName = pcd.YuYueWeiDu.Name;
                pcd.PaiDuiSeq = pcd.YuYueWeiDu.PaiDuiSeq;
            }

            switch (pcd.BillTypeId)
            {
                case PCDBillTypeUtil.BZCGLPCD:
                case PCDBillTypeUtil.DRJHPCD:
                case PCDBillTypeUtil.XSTHLPCD:
                    pcd.IsOutStock = false;

                    break;
            }

            return pcd;
        }
        public static string GetTruckTypeName(string id)
        {
            var name = "";
            if (string.IsNullOrWhiteSpace(id)) return name;

            var item = RedisManager.GetObject<WXVoitureType>(id);
            if (item != null)
            {
                name = item.Name;
            }

            return name;
        }

        /// <summary>
        /// 用星号模糊化身份证号码
        /// </summary>
        /// <param name="idCardNo"></param>
        /// <returns></returns>
        public static string SetIDCardNoByAsterisk(string idCardNo)
        {
            if (string.IsNullOrWhiteSpace(idCardNo)) return string.Empty;

            try
            {
                var arr = idCardNo.Trim().ToCharArray();
                for (var index = 0; index < arr.Length; index++)
                {
                    if (index >= 6 && index <= 13)
                    {
                        arr[index] = '*';
                    }
                    if (index == arr.Length - 1)
                    {
                        arr[index] = '*';
                    }
                }

                return new string(arr);
            }
            catch
            {
                return string.Empty;
            }
        }
    }
    [Serializable]
    public class WXPCDEntryRow
    {
        public WXPCDEntryRow()
        {
        }
        public string MaterialNumber { get; set; }
        public string MaterialName { get; set; }
        public string Specification { get; set; }
        public decimal PlanQty { get; set; }
        public string Unit { get; set; }

        public decimal LiHuoQty { get; set; }
        public string LiHuoUnit { get; set; }
        public decimal TaxPrice { get; set; }
        public decimal JieSuanQty { get; set; }
        public string BaseUnit { get; set; }
        public string Stock { get; set; }
    }
    /// <summary>
    /// 小程序派车计划信息
    /// </summary>
    public class WXPCJHItem
    {
        public string Note { get; set; }
        public string TruckTypeId { get; set; }
        public string TruckTypeName { get; set; }
        public string ForbidStatus { get; set; }
        public string Operation { get; set; }
        public decimal YunFeiPrice { get; set; }
        public decimal Qty { get; set; }
        public string Mobile { get; set; }
        public string IDCardNo { get; set; }
        public string Driver { get; set; }
        public string PlateNumber { get; set; }
        public Int64 Id { get; set; }

        public string ExpiryTime { get; set; }
        /// <summary>
        /// 道路运输证号
        /// </summary>
        public string RoadTransportCN { get; set; }
        /// <summary>
        /// 从业资格证号
        /// </summary>
        public string EmploymentQualificationCN { get; set; }
        public WXCheZhou CheZhou { get; set; }

        public WXPCJHItem()
        {
            this.ForbidStatus = "A";
            this.TruckTypeId = "555aa682e1c2c7";
            this.TruckTypeName = "普通车";
            this.CheZhou = new WXCheZhou();
        }
    }
    /// <summary>
    /// 车轴
    /// </summary>
    public class WXCheZhou
    {
        public WXCheZhou()
        {
            this.Number = "";
            this.Name = "";
        }
        public Int64 Id { get; set; }
        public string Number { get; set; }
        public string Name { get; set; }
        public decimal ZaiZhong { get; set; }
    }
    /// <summary>
    /// 扣杂比例
    /// </summary>
    public class WXKouZaItem
    {
        public WXKouZaItem()
        {
            this.Number = "";
            this.Name = "";
        }
        public decimal Id { get; set; }
        public string Number { get; set; }
        public string Name { get; set; }
    }
    public class WXFuZhuZiLiao : BaseDataItem<string>
    {
        public WXFuZhuZiLiao()
        {
            Id = " ";
            Number = "";
            Name = "";
            FormId = "BOS_ASSISTANTDATA_SELECT";
            FzzlTypeId = "";
        }

        public string FormId { get; set; }
        public string FzzlTypeId { get; set; }
    }

    /// <summary>
    /// 车辆类型
    /// </summary>
    public class WXVoitureType
    {
        public WXVoitureType()
        {
            this.Id = "";
            this.Number = "";
            this.Name = "";
        }
        public string Id { get; set; }
        public string Number { get; set; }
        public string Name { get; set; }
    }
    /// <summary>
    /// 车辆
    /// </summary>
    public class WXVoiture
    {
        public WXVoiture()
        {
            this.TruckTypeId = "555aa682e1c2c7";
        }
        /// <summary>
        /// 用户令牌
        /// </summary>
        public string UserToken { get; set; }
        /// <summary>
        /// Id为空，新增；Id不为空，更新；
        /// </summary>
        public string Id { get; set; }
        /// <summary>
        /// 司机
        /// </summary>
        public string Driver { get; set; }
        /// <summary>
        /// 手机号码
        /// </summary>
        public string Mobile { get; set; }
        /// <summary>
        /// 身份证号码
        /// </summary>
        public string IDCardNo { get; set; }
        /// <summary>
        /// 车牌号码
        /// </summary>
        public string PlateNumber { get; set; }
        /// <summary>
        /// 道路运输证号
        /// </summary>
        public string RoadTransportCN { get; set; }
        /// <summary>
        /// 从业资格证号
        /// </summary>
        public string EmploymentQualificationCN { get; set; }
        /// <summary>
        /// 车轴
        /// </summary>
        public WXCheZhou CheZhou { get; set; }
        /// <summary>
        /// 车辆类型
        /// </summary>
        public string TruckTypeId { get; set; }
    }

    /// <summary>
    /// 源单派车计划
    /// </summary>
    [Serializable]
    public class WXPCDSourceBillObject
    {
        public WXPCDSourceBillObject()
        {
            this.Timestamp = "";
            this.PCDSourceBillObject = new PCDSourceBillObject();
        }
        public string Id { get; set; }
        public string Timestamp { get; set; }
        public PCDSourceBillObject PCDSourceBillObject { get; set; }
    }
    public class WXPCDSGFXItem
    {
        public WXPCDSGFXItem()
        {
            this.Id = Guid.NewGuid().ToString();
            this.Handler_Time = DateTime.Now;
            this.Handler_Note = "";
        }
        public string Handler_UserToken { get; set; }
        public string Handler_Name { get; set; }
        public string Handler_Phone { get; set; }
        /// <summary>
        /// 手工放行时间
        /// </summary>
        public DateTime Handler_Time { get; set; }
        public string Handler_Note { get; set; }

        public string Id { get; set; }
        public Int64 BillId { get; set; }
        public string BillNo { get; set; }
        /// <summary>
        /// 业务对象标识
        /// </summary>
        public string FormId { get; set; }
        public string BillTypeId { get; set; }
        public string BillTypeName { get; set; }

        public string BillDate { get; set; }
        /// <summary>
        /// RFID卡号
        /// </summary>
        public string RFIDTag { get; set; }

        /// <summary>
        /// 身份证号
        /// </summary>
        public string IDCardNo { get; set; }
        /// <summary>
        /// 往来单位
        /// </summary>
        public string WLDWName { get; set; }
        /// <summary>
        /// 往来单位联系人
        /// </summary>
        public string WLDWContactName { get; set; }
        /// <summary>
        /// 往来单位联系电话
        /// </summary>
        public string WLDWPhoneNumber { get; set; }
        /// <summary>
        /// 往来单位联系地址
        /// </summary>
        public string WLDWAddress { get; set; }
        /// <summary>
        /// 库存组织
        /// </summary>
        public string StockOrg { get; set; }
        /// <summary>
        /// 是否出库
        /// </summary>
        public bool IsOutStock { get; set; }

        /// <summary>
        /// 车牌号
        /// </summary>
        public string PlateNumber { get; set; }
        /// <summary>
        /// 司机
        /// </summary>
        public string Driver { get; set; }
        /// <summary>
        /// 手机号
        /// </summary>
        public string MobilePhoneNumber { get; set; }
        /// <summary>
        /// 车辆类型
        /// </summary>
        public string TruckTypeId { get; set; }
        /// <summary>
        /// 车辆类型名称
        /// </summary>
        public string TruckTypeName { get; set; }

        public static WXPCDSGFXItem Parse(WXPCD obj)
        {
            var pcd = new WXPCDSGFXItem();
            pcd.RFIDTag = obj.RFIDTag;
            pcd.BillDate = obj.BillDate;
            pcd.BillId = obj.BillId;
            pcd.BillNo = obj.BillNo;
            pcd.BillTypeId = obj.BillTypeId;
            pcd.BillTypeName = obj.BillTypeName;

            pcd.FormId = obj.FormId;
            pcd.Driver = obj.Driver;
            pcd.IDCardNo = obj.IDCardNo;
            pcd.PlateNumber = obj.PlateNumber;
            pcd.MobilePhoneNumber = obj.MobilePhoneNumber;
            pcd.IDCardNo = obj.IDCardNo;
            pcd.TruckTypeId = obj.TruckTypeId;
            pcd.TruckTypeName = obj.TruckTypeName;

            pcd.WLDWName = obj.WLDWName;
            pcd.WLDWContactName = obj.WLDWContactName;
            pcd.WLDWAddress = obj.WLDWAddress;
            pcd.WLDWPhoneNumber = obj.WLDWPhoneNumber;
            pcd.StockOrg = obj.StockOrg;
            pcd.Handler_Note = obj.ChongXinLiHuoYuanYin;
            pcd.IsOutStock = obj.IsOutStock;

            return pcd;
        }
    }
}